home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / sos3-2.lha / bin / sos-cmp < prev    next >
Text File  |  1992-02-13  |  4KB  |  111 lines

  1. #!/bin/sh
  2. # --------------------------------------------------------------------------
  3. # Copyright 1992 by Forschungszentrum Informatik (FZI)
  4. #
  5. # You can use and distribute this software under the terms of the licence
  6. # you should have received along with this program.
  7. # If not or if you want additional information, write to
  8. # Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
  9. # D-7500 Karlsruhe 1, Germany.
  10. # --------------------------------------------------------------------------
  11. # 'sos-cmp - 27:02:91 - Dietmar Theobald'
  12. #
  13. # sos-cmp [-v] [-E] [-I] [-L <language>] <file_prefix> [<schema>]
  14. #
  15. # Interface to the SOS compiler and host language generators. A compilation is
  16. # carried out in two phases: In the first phase a schema file is processed and
  17. # an schema object as an internal representation is generated which is placed in
  18. # the root container. The second phase operates on this schema object and 
  19. # produces a host language interface to the classes and types defined in the 
  20. # schema.
  21. #
  22. # The "-v" option causes a report on the start of each compilation phase.
  23. #
  24. # The "-E" flag takes effect on the first phase by enabling an echo mode. This
  25. # echo is generated by the lexical analyzer module of the SOS compiler and
  26. # consists of the text of an token before this token is handed over to the parser
  27. # module. The echo mode is intended to be used in debugging the SOS compiler.
  28. # The "-L" option specifies the host language interface to be generated. Up to
  29. # now there exists only a C++ binding, which is also the default.
  30. #
  31. # <file_prefix> may be:
  32. #    "^"       : The first phase is not carried out.
  33. #    "-"       : Input is read from stdin.
  34. #    another string: Input is read from "<file_prefix>.sos".
  35. #
  36. # <schema> may be:
  37. #    "^"       : The second phase is not carried out.
  38. #    another string: Output is generated for the named <schema>.
  39. #             The output is written to the current working directory.
  40. # If <schema> is not given then <file_prefix> is also used as schema name. This
  41. # is not possible if <file_prefix> is "^" or "-".
  42. #
  43. BINDIR=${SOSPATH-__SOS_INSTALLED_PATH__}/bin/
  44.  
  45. test="${SOSCONTAINER?}"
  46.  
  47.  tmpfile=/tmp/sos-cmp.$$
  48. language='CC'
  49.  
  50. while [ $# -gt 0 ]
  51. do
  52.    case $1 in
  53.       -v) verbose='+'    ;;
  54.       -E) cfeopt='-E'    ;;
  55.       -I) genopt='-I'    ;;
  56.       -L) shift
  57.       language="$1"    ;;
  58.        *) break        ;;
  59.    esac
  60.    shift
  61. done
  62.  
  63. generator="gen$language"
  64.  
  65. if [ $# -eq 1 ] ; then
  66.    [ "$1" = '^' -o "$1" = '-' ] && {
  67.       echo >&2 '*** sos-cmp: no implicit schema name' ; exit 1
  68.       }
  69.    infile="$1".sos
  70.    schema="`basename $1`"
  71. elif [ $# -eq 2 ] ; then
  72.    if [ "$1" = '-'  -o "$1" = '^' ] ; then
  73.       infile="$1"
  74.    else
  75.       infile="$1".sos
  76.    fi
  77.    schema="$2"
  78. else
  79.    echo >&2 '*** usage: sos-cmp [-E] [-I] [-L language] file-prefix [schema-name]'
  80.    exit 1
  81. fi
  82.  
  83.  
  84. [ "$infile" != '^' ] && { [ "$verbose" ] && \
  85.                  echo 'sos-cmp: starting compilation ...'
  86.  
  87.               if [ $infile = '-' ] ; then
  88.                  cat - > $tmpfile
  89.                
  90.                              ${BINDIR}cfe $cfeopt $tmpfile || { rm $tmpfile
  91.                                     exit 1
  92.                                   }
  93.                              rm $tmpfile
  94.                           else
  95.                              ${BINDIR}cfe $cfeopt $infile || exit 1
  96.                           fi
  97.                         }
  98.  
  99. [ "$schema" != '^' ] && {
  100.    [ "$verbose" ] && echo 'sos-cmp: starting generation ...'
  101.  
  102.    genfiles="${schema}_sos.c ${schema}_sos.h ${schema}_use.h"
  103.  
  104.    rm -f $genfiles
  105.    
  106.    ${BINDIR}$generator $genopt $schema || exit 1
  107.    }
  108.  
  109. exit 0
  110.